Disable exclusive edit

Hi,

We have some modules that we don't want people open in exclusive edit, we just want people open them in shareable edit.

 

Is that possible? Maybe with a trigger o something

 

Thank you!


Juanfergar - Mon Jan 22 05:06:22 EST 2018

Re: Disable exclusive edit
Mike.Scharnow - Mon Jan 22 05:35:11 EST 2018

some code we used in the past for a "Lock Module Trigger" which should not allow modules to be opened in certain "module states" (i.e. approved).

The missing function "getUserPermission" has to find out whether the user is acutally allowed to open the module or not. You will not limit ALL users from open a module in exclusive edit mode, otherwise you would never be able to add attributes or do similar things to a module.

 

trigger code:

if (!null T) {

        Module m = (module T) 
        if (!null m && "Formal" == type m) {
            ModuleVersion mvM = version (T)
            if ("" != versionString (mvM))  {
                // baselines can always be opened
            } else {
            // print "The module " (fullName (m)) " is 'Lock module protected' ...\n"
                Permission perm  = getUserPermissionForState (find(), module m)
            // TBD: did an error occur? treat it accordingly...
                      
            if ( (perm & modify != modify) && (isEdit m || isShare m) ) {
                // sanity check
                if (unsaved m) then {
                    // downgrade will discard all changes. Too dangerous.... 
                    ack "You found a bug. Please contact the DOORS Administrator to receive your reward. (Please save your changes now)."
                } else { 
                    downgrade m 
                    ack "You cannot open this module in edit mode, since ... add your reason here ..."
                }
            }
            }
        } else {
            //print "???"
        }
}

 

code to install the trigger:

void installTriggers(Project p, ...

[…]

string lockModuleTriggerName  = lockModuleTriggerScript "_" name (p)  

[… check whether trigger is already installed ...]

    current = p

 T = trigger (lockModuleTriggerName, project->module->all, post, open, 10, "#include <../lib/triggers/" lockModuleTriggerScript ".dxl>")

    if (null T) print "Trigger " lockModuleTriggerName " could not be installed!\n"

 

PS: develop and test thoroughly!!!!! on a test database before you do any changes to productive modules / projets

Re: Disable exclusive edit
Juanfergar - Wed Jan 24 09:45:34 EST 2018

Thanks.

 

I get it with the next code. The code allow the users in the group "nameGroupAdministrator" open the module in Exclusive Edit, everyone Else only can open the module in Read or Shareable Edit mode.

 

if (isEdit(current Module)){
        User myUser
        Group administration = find("nameGroupAdministrator")
        bool admin = false
        for myUser in administration do{
                string myUserName = myUser.name
                if(myUserName == doorsname)     {
                        admin = true
                        break
                }
        }
        if (!admin){
                downgrade current Module
                ack "Exclusive Edit is disabled in this module. You have to open the module in SHAREABLE EDIT MODE."
        }
}

And the code to install the trigger:

trigger ("nameTrigger", project->module->all, post, open, 10, "#include <path/archive.dxl>")

 

Re: Disable exclusive edit
Mike.Scharnow - Wed Jan 24 10:36:55 EST 2018

Juanfergar - Wed Jan 24 09:45:34 EST 2018

Thanks.

 

I get it with the next code. The code allow the users in the group "nameGroupAdministrator" open the module in Exclusive Edit, everyone Else only can open the module in Read or Shareable Edit mode.

 

if (isEdit(current Module)){
        User myUser
        Group administration = find("nameGroupAdministrator")
        bool admin = false
        for myUser in administration do{
                string myUserName = myUser.name
                if(myUserName == doorsname)     {
                        admin = true
                        break
                }
        }
        if (!admin){
                downgrade current Module
                ack "Exclusive Edit is disabled in this module. You have to open the module in SHAREABLE EDIT MODE."
        }
}

And the code to install the trigger:

trigger ("nameTrigger", project->module->all, post, open, 10, "#include <path/archive.dxl>")

 

just one remark: Is it intentional that "normal" users are not allowed to edit Link Modules (to create link sets), otherwise you might want to consider the scope module->formal

Re: Disable exclusive edit
Juanfergar - Wed Jan 24 10:40:26 EST 2018

Mike.Scharnow - Wed Jan 24 10:36:55 EST 2018

just one remark: Is it intentional that "normal" users are not allowed to edit Link Modules (to create link sets), otherwise you might want to consider the scope module->formal

Thank you, it's a good remark, but in this case it's intentional, I just want that users modify some attributes in some modules.

 

Thanks for your answers!

Re: Disable exclusive edit
Mike.Scharnow - Thu Jan 25 08:06:42 EST 2018

Juanfergar - Wed Jan 24 10:40:26 EST 2018

Thank you, it's a good remark, but in this case it's intentional, I just want that users modify some attributes in some modules.

 

Thanks for your answers!

Oh, I see that there is a quite new perm "downgradeShare". might be useful in your script...

Re: Disable exclusive edit
Juanfergar - Thu Jan 25 08:25:12 EST 2018

Mike.Scharnow - Thu Jan 25 08:06:42 EST 2018

Oh, I see that there is a quite new perm "downgradeShare". might be useful in your script...

Yes, it's true, with that the user is in shareable edit automatically. Thanks!!